package com.example.blog.mapper;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.blog.domain.UserInformation;
import com.example.blog.domain.Users;
import com.example.blog.domain.Writings;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.data.repository.query.Param;
import org.springframework.security.core.userdetails.User;

import java.util.List;
import java.util.Map;

@Mapper
public interface UserInformationMapper extends BaseMapper<UserInformation> {

    //获取所有Admin用户信息
    @Select("select i.* from user_info i " +
            "left join user_role r on r.uid = i.uid " +
            "where r.rid = 2 limit #{index},#{page}")
    List<UserInformation> AdminInfo(@Param("index") Integer index, @Param("page") Integer page);

    //统计Admin用户信息
    @Select("select count(i.uid) from user_info i left join user_role r on r.uid = i.uid where r.rid = 2")
    long statisticsAdminInfo();


    //统计所有用户数量
    @Select("select count(uid)  from user_info")
    long userLength();


    //今日累计登录
    @Select("select count(uid) from user_info where to_days(last_logon_time) = to_days(now())")
    long loginDay();
}
